/*
 * @Description:
 * @version:
 * @Author: sunqian_sr
 * @Date: 2023-01-05 15:27:16
 * @LastEditors: Andy
 * @LastEditTime: 2023-01-12 13:53:21
 */
import { mapState, mapActions } from 'pinia'
import { pinias } from '@/common/pinia'

const { dictValue } = pinias
const dictStore = dictValue()
const QueryDictMixin = {
  data() {
    return {
      dictOptions: {},
      dictKeys: []
    }
  },
  computed: {},
  methods: {
    initDictConfig() {
      if (this.dictKeys?.length) {
        for (let i = 0; i < this.dictKeys.length; i++) {
          this.$set(this.dictOptions, this.dictKeys[i], [])
          this.getDictConfig(this.dictKeys[i])
        }
      }
    },
    getDictConfig(dictKey) {
      dictStore.getSelectionDict(dictKey).then((data) => {
        this.dictOptions[dictKey] = JSON.parse(
          JSON.stringify(data).replaceAll('dictLabel', 'label').replaceAll('dictValue', 'value')
        )
      })
    }
  }
}
export default QueryDictMixin
